<template>
  <a-form-model
    :ref="'anamnesis' + confirmType"
    :model="anamnesis"
    :label-col="formItemLayout.labelCol"
    :wrapper-col="formItemLayout.wrapperCol"
    labelAlign="left"
  >
    <a-form-model-item label="确诊情况">
      <a-radio-group v-model="anamnesis.dnhs">
        <a-radio :value="1"> 确诊有 </a-radio>
        <a-radio :value="2"> 确诊无 </a-radio>
        <a-radio :value="3"> 未确诊 </a-radio>
      </a-radio-group>
    </a-form-model-item>
    <a-divider />
    <div class="content" v-show="anamnesis.dnhs === 1">
      <a-form-model-item label="发生频率">
        <a-input-number v-model="anamnesis.dnhsFrequency" :min="0" :max="999" :style="{ width: '200px' }" />
        次/周
      </a-form-model-item>
    </div>
    <a-form-model-item :wrapper-col="{ span: 12, offset: 10 }">
      <a-button type="primary" @click="save" :loading="saveLoading">保存</a-button>
      <a-popconfirm placement="topLeft" ok-text="是" cancel-text="否" @confirm="confirm">
        <template slot="title">
          <p>此操作代表你已完成了页面的填写，是否继续？</p>
        </template>
        <a-button type="primary" style="margin-left: 30px" :loading="saveLoading">确认完成</a-button>
      </a-popconfirm>
    </a-form-model-item>
  </a-form-model>
</template>

<script>
export default {
  name: 'DiabeticHyperosmolarSyndrome',
  props: ['anamnesis'],
  data() {
    return {
      confirmType: 3,
      formItemLayout: {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 4 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        }
      },
      saveLoading: false
    }
  },
  methods: {
    save() {
      this.saveLoading = true
      this.$emit('save', this.confirmType)
    },
    confirm() {
      this.saveLoading = true
      this.$emit('confirm', this.confirmType)
    }
  }
}
</script>

<style lang="less" scoped></style>
